package com.sysu.homework.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.sun.istack.internal.Nullable;

@Entity
@Table(name="my_group")
public class Group {
	private int id;
	private String name;
	private Student groupLeader;
	private String description;
	private boolean isLock;
	private List<Student> students =  new ArrayList<Student>();
	
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@OneToOne(fetch=FetchType.EAGER)
	public Student getGroupLeader() {
		return groupLeader;
	}
	public void setGroupLeader(Student groupLeader) {
		this.groupLeader = groupLeader;
	}
	
	@OneToMany(mappedBy="group")
	public List<Student> getStudents() {
		return students;
	}
	public void setStudents(List<Student> students) {
		this.students = students;
	}
	public void setIsLock(boolean isLock) {
		this.isLock = isLock;
	}
	
	@Column(nullable=true)
	public boolean getIsLock() {
		return isLock;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getDescription() {
		return description;
	}
	
}
